<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Person {
            // 公有属性
            name;
            // 私有属性
            #age;
            #weight;
            // 构造方法
            constructor(name, age, weight) {
                this.name = name;
                this.#age = age;
                this.#weight = weight;
            }

            // 参考java的set get方法
            intro() {
                console.log(this.name);
                console.log(this.#age);
                console.log(this.#weight);
            }
        }
        // 实例化
        const girl = new Person('小明', 18, '45kg');
        console.log(girl);//Person {name: '小明', #age: 18, #weight: '45kg'}
        console.log(girl.name);//小明
        console.log(girl.age);//undefind
        console.log(girl.weight);//undefind

        girl.intro();//小明 18 45kg
    </script>
</body>

</html>